All Questions
352 questions
4votes
3answers
533views
Parse console output and audibly say error
I am testing testing app by running mycommand that outputs at the console and directly at /tmp/mycommand.log. Using zsh. mycommand is really a function with parameters, but I can get the same when ...
1vote
2answers
87views
Filter for arbitrary AND patterns [duplicate]
Consider a command which takes arguments like this: cmd foo bar baz [arbitrary args...]. How do you build a filter of AND patterns based on those arguments? Something like this pipeline of greps: grep ...
0votes
4answers
172views
bash - slice quoted substrings delimited by spaces into array
following example: string=" 'f o o' 'f oo' 'fo o' " array=($string) echo "${array[0]}" outputs: 'f while the expected output is: 'f o o' The only solution I came with is by ...
2votes
3answers
228views
How to highlight the matched regex pattern got by many regex exps disjoined with `||` in awk?
This highlight feature can be done easily in grep with --color. But grep can't do regular and invert match at the same time, e.g. grep foo -v bar ... (I need this feature since --color can be only ...
-1votes
1answer
87views
As soon as I touch a new file, my ls command with grep stops working [duplicate]
I'm trying to find all the files in my home directory with a specific extension. If I only have one instance of the file extension, the ls command works perfectly fine, but as soon as I touch a new ...
0votes
1answer
120views
How to use the -E option of grep matching some variable name
We want to know about the correct method for matching some variable name(including its $ prefix) via using the grep -E option. It seems that this grep macthing function can only work with either no ...
0votes
1answer
187views
Grep: Throw if found and show output
I'm struggling getting these two to work together: Exit with error code 1 if grep finds. Show either the whole output or the line where it matched. Right now I have the first, if grep matches, it ...
1vote
1answer
89views
Remove entire folder when grep find no files with a match inside the folder
I have thousands of folders with a single html file in each folder. I want to remove the entire folder if grep find no match to example.com in the html file. I know how to remove the non matching file....
0votes
3answers
2kviews
Shell extract full word matching partial pattern
I need to extract a word from a line in a shell script, I've seen similar examples though none of which worked. Take the example sentence word1 word2 word3/pattern/word4.word5 word6 Given pattern it ...
0votes
1answer
528views
How to grep "find -print0" output?
I tried this: find /usr/lib -print0 | grep zip | xargs -0 -I{} echo "found file: {}" find /usr/lib -print0 | grep --null zip | xargs -0 -I{} echo "found file: {}" But it doesn't ...
1vote
1answer
248views
Finding the occurence of a word in a subfolder
Hello i'm trying to find all occurrences of a word in a subfolder. While that seems to be easy i want that for each occurrence we will display the path and the name of the file followed by ' -> ...
0votes
6answers
258views
search pattern and print in same line
I have a big .txt file in below format Pin name="AR_OP" status="f" Pref x=997.6800 y=2327.0400 side=N width=0.0400 depth=0.3750 / Layer id=1 -- Pin name="...
2votes
1answer
112views
Remove all the strings before and after a certain word in bash
I am using ping to check the connectivity of a network. What I want is the number of received packets only. For example if ping -c10 -q 8.8.8.8 | grep received output is: 10 packets transmitted, 5 ...
5votes
3answers
649views
Copy files using an input file to read file directions
I'm using grep to search through 1 TB of files. I want to grep filenames and put the names in a text file AND I want to cp all files with a match to the dir /home/user/matches. I want to both tasks ...
0votes
3answers
687views
compare multiple files in bash script
bash and shell programming is new for me.I have a few files with the extension .v.gz, in the bash command I am performing some operations, and ill store the result in the same filename with .txt ...